<?php

namespace App\Kuafu\Complain\Validate;

use Illuminate\Http\Request;
use App\Kuafu\Base\Validate\BaseValidate;
use Illuminate\Validation\Rule;

class ComplainValidate extends BaseValidate
{

    /**
     * 投诉建议添加参数验证
     *
     * @param Request $request
     * @return string
     */
    public static function addComplain(Request $request)
    {
        $rules    = [
            'orderId'        => Rule::when(
                str_contains($request->route()->uri(), "v2"),
                "",
                'required|integer|min:0'
            ),
            'reason'         => 'required|string|max:50',
            'problemPid'     => 'required|integer|min:0',
            'problemChildId' => 'required|integer|min:0',
            'desc'           => 'required|string|max:255',
            'img'            => 'required|array',
            'phone'          => 'required|string|max:32',
        ];
        $messages = [];
        return self::validateCheck($request->all(), $rules, $messages);
    }

    /**
     * 投诉建议修改参数验证
     *
     * @param Request $request
     * @return string
     */
    public static function updateComplain(Request $request)
    {
        $rules    = [
            'remark' => 'filled|string|max:255',
        ];
        $messages = [];
        return self::validateCheck($request->all(), $rules, $messages);
    }
}
